const users = [
  { id: 1, name: '张三' },
  { id: 2, name: '李四' },
  { id: 3, name: '王五' },
  { id: 4, name: '赵六' },
];

const phones = [
  {
    phone: '小米15',
    ref: {
      brand: '小米',
      // price: 5000,
      color: 'white',
    },
  },
  {
    phone: '苹果16',
    ref: {
      brand: '苹果',
      price: 10000,
      // color: 'red'
    },
  },
  {
    phone: '华为17',
    ref: {
      brand: '华为',
      price: 8000,
      color: 'black',
    },
  },
];

export default {
  'GET /api/v1/user': (req: any, res: any) => {
    res.json({
      success: true,
      data: { list: users },
      errorCode: 0,
    });
  },
  'GET /api/v1/user/:id': (req: any, res: any) => {
    const user = users.find((item) => item.id === parseInt(req.params.id));

    const userDetail = user
      ? {
          ...user,
          phones,
        }
      : null;

    res.json({
      success: true,
      data: userDetail,
      errorCode: 0,
    });
  },
};
